package com.yzqp.blog.runtime;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 项目运行后自动运行的代码
 */
@Component
public class ApplicationRunner implements org.springframework.boot.ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) throws Exception {

    }

    //    @Autowired
//    private QuestionService questionService;
//
//    @Override
//    public void run(ApplicationArguments args) throws Exception {
////        // 初始化问题模板
//////        changeQuestionTemplet();
//////        // 初始化段落
//////        changeStage();
//    }
//
//    private void changeQuestionTemplet() {
//        List<Question> list = questionService.findAllList();
//        for(Question question : list){
//            String content = question.getContent();
//            content = content.replaceAll("<br>", "<br/>");
//            question.setContent(content);
//
//            String analyze = question.getAnalyze();
//            analyze = analyze.replaceAll("<br>", "<br/>");
//            question.setAnalyze(analyze);
//            questionService.update(question);
//        }
//    }
//
//    private void changeStage() {
//        List<Question> list = questionService.findAllList();
//        for(Question question : list){
//            String content = question.getContent();
//            content = content.replaceAll("<br/>", "<br/>     ");
//            question.setContent(content);
//
//            String analyze = question.getAnalyze();
//            analyze = analyze.replaceAll("<br/>", "<br/>     ");
//            question.setAnalyze(analyze);
//            questionService.update(question);
//        }
//    }
}

